// pages/detail/detail.js
import {
  request
} from '../../request/index.js';
import regeneratorRuntime from '../../lib/runtime/runtime.js'

Page({

  /**
   * 页面的初始数据
   */
  data: {
    videoInfo: [],
    otherList: [],
    commentList:[]
  },

 getVideoInfo(videoId) {
    let that = this;
    wx.request({
      url: 'https://www.fastmock.site/mock/0cc8353a68511aad722aa387610a4ce1/bili/videoDetail?id='+videoId,
      success(res) {
        if (res.data.code == 0) {
          that.setData({
            videoInfo: res.data.videoInfo.video
          })
        }
      }
    })
  },
  async getOtherList(videoId) { 
    const res = await request({ url: "/otherList?id=" + videoId });
    this.setData({
      otherList:res.data.data.otherList
    })
  },
  async getCommentList(videoId) { 
    const res = await request({ url: "/commentList?=" + videoId });
    this.setData({
      commentList:res.data.data.commentData
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    const videoId = options.id;
    this.getVideoInfo(videoId);
    this.getOtherList(videoId);
    this.getCommentList(videoId);
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})